package cn.song.config;

import com.lly835.bestpay.config.WxPayH5Config;
import com.lly835.bestpay.service.impl.BestPayServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class WeChatPayConfig {

    @Autowired
    private  WecharAcountConfig wecharAcountConfig;

    @Bean
    public BestPayServiceImpl getBestPayService(){
        BestPayServiceImpl bestPayService = new BestPayServiceImpl();
        bestPayService.setWxPayH5Config(getWxPayH5config());
        return  bestPayService;

    }

    @Bean
    public WxPayH5Config getWxPayH5config(){
        WxPayH5Config wxPayH5Config = new WxPayH5Config();
        wxPayH5Config.setAppId(wecharAcountConfig.getMpAppId());
        wxPayH5Config.setAppSecret(wecharAcountConfig.getMpAppSecret());
        wxPayH5Config.setMchId(wecharAcountConfig.getMchId());
        wxPayH5Config.setMchKey(wecharAcountConfig.getMchKey());
        wxPayH5Config.setKeyPath(wecharAcountConfig.getKeyPath());
        wxPayH5Config.setNotifyUrl(wecharAcountConfig.getNotifyUrl());
        return wxPayH5Config;
    }
}
